package com.xuedakun.xasdk.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by xuedakun on 2017/6/3 14:38
 * EventBus的操作封装
 *
 * @version : v1.0
 * @project : xasdk
 * @Email : dakun611@Gmail.com
 */

public class EventBusUtils {

    /**
     * 在需要接收消息的页面注册
     *
     * @param subscriber
     */
    public static void register(Object subscriber) {
        EventBus.getDefault().register(subscriber);
    }

    /**
     * 接收完之后解除注册
     *
     * @param subscriber
     */
    public static void unRegister(Object subscriber) {
        EventBus.getDefault().unregister(subscriber);
    }

    /**
     * 发送消息
     */
    public static void post(int what, Object msg) {
        EventBus.getDefault().post(new EventBusMessage(what, msg));
    }

    /**
     * 发送简单消息
     *
     * @param what
     */
    public static void post(int what) {
        post(what, null);
    }
}
